/******************************************************************************
* File description: experimentSetting.qml
* Function: 实验设置页面
* Current Version: 1.0.0
* Author: 张宇轩
* Date: 2024-08-30
*  -----
*  Copyright by 博坤生物 .
 *****************************************************************************/
import QtQuick 2.14
import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14
import QtGraphicalEffects 1.14

Item {
    id: root

    /* property 定义开始 */
    // 信号
    signal nextPage(); // 切换到下一页
    signal prevPage(); // 切换到上一页
    signal returnSig();
    signal changeSettingPage(int index)
    signal aboutUs()
    signal help()
    /* property 定义结束 */

    // tabbar nav
    TabbarNav {
        id: navBar
        width: parent.width
        height: 56
        title: "设置"
        z: 999

        onReturnSig: {
            root.returnSig()
        }
    }

    ColumnLayout {
        anchors.fill: parent
        spacing: 0

        // 主体部分
        Rectangle {
            id: mainPart
            Layout.fillWidth: true
            Layout.fillHeight: true
            Layout.alignment: Qt.AlignTop

            // 背景
            Rectangle {
                anchors.fill: parent
                LinearGradient {
                    anchors.fill: parent
                    start: Qt.point(0, 0)
                    end: Qt.point(0, height)
                    gradient: Gradient {
                        GradientStop {position: 0.0; color: "#007BD8"}
                        GradientStop {position: 1.0; color: "#001A5A"}
                    }
                }
            }

            Rectangle {
                anchors.fill: parent
                anchors.topMargin: 16 + navBar.height
                anchors.leftMargin: 16
                anchors.rightMargin: 16
                anchors.bottomMargin: 16
                color: "#C3FFFFFF"
                border.width: 0
                radius: 12

                // 内容
                GridLayout {
                    id: contentLayout
                    width: (contentLayout.children[0].width + columnSpacing) * contentLayout.rows
                    height: (contentLayout.children[0].height + rowSpacing) * contentLayout.columns
                    anchors.centerIn: parent
                    anchors.verticalCenterOffset: -80
                    columns: 3
                    rows: 3
                    columnSpacing: 16
                    rowSpacing: 16

                    // 导出设置
                    SettingButton {
                        id: exportSettingBtn
                        Layout.preferredWidth: 256
                        Layout.preferredHeight: 80
                        settingBtnText: "导出设置"
                        defBtnImgUrl: "qrc:/icons/setting_export.png"
                        hoveredBtnImgUrl: "qrc:/icons/setting_export_hovered.png"
                        onReleased: {
                            root.changeSettingPage(1)
                        }
                    }

                    // 默认设置
                    SettingButton {
                        id: defaultSettingBtn
                        Layout.preferredWidth: 256
                        Layout.preferredHeight: 80
                        settingBtnText: "默认设置"
                        defBtnImgUrl: "qrc:/icons/setting_default.png"
                        hoveredBtnImgUrl: "qrc:/icons/setting_default_hovered.png"
                        onReleased: {
                            root.changeSettingPage(2)
                        }
                    }

                    // 数据统计
                    SettingButton {
                        id: dataCalBtn
                        Layout.preferredWidth: 256
                        Layout.preferredHeight: 80
                        settingBtnText: "数据统计"
                        defBtnImgUrl: "qrc:/icons/setting_expdata.png"
                        hoveredBtnImgUrl: "qrc:/icons/setting_expdata_hovered.png"
                        onReleased: {
                            root.changeSettingPage(3)
                        }
                    }

                    // 偏好设置
                    SettingButton {
                        id: preferenceSettingBtn
                        Layout.preferredWidth: 256
                        Layout.preferredHeight: 80
                        settingBtnText: "偏好设置"
                        defBtnImgUrl: "qrc:/icons/setting_preference.png"
                        hoveredBtnImgUrl: "qrc:/icons/setting_preference_hovered.png"
                        onReleased: {
                            root.changeSettingPage(4)
                        }
                    }

                    // 网络连接
                    SettingButton {
                        id: connectionBtn
                        Layout.preferredWidth: 256
                        Layout.preferredHeight: 80
                        settingBtnText: "网络连接"
                        defBtnImgUrl: "qrc:/icons/setting_connection.png"
                        hoveredBtnImgUrl: "qrc:/icons/setting_connection_hovered.png"
                        onReleased: {
                            root.changeSettingPage(5)
                        }
                    }

                    // 实验恢复
                    SettingButton {
                        id: expRestoreBtn
                        Layout.preferredWidth: 256
                        Layout.preferredHeight: 80
                        settingBtnText: "实验恢复"
                        defBtnImgUrl: "qrc:/icons/setting_restore.png"
                        hoveredBtnImgUrl: "qrc:/icons/setting_restore_hovered.png"
                        onReleased: {
                            root.changeSettingPage(6)
                        }
                    }

                    // 模型配置
                    SettingButton {
                        id: modelConfBtn
                        Layout.preferredWidth: 256
                        Layout.preferredHeight: 80
                        settingBtnText: "模型配置"
                        defBtnImgUrl: "qrc:/icons/setting_modelconf.png"
                        hoveredBtnImgUrl: "qrc:/icons/setting_modelconf_hovered.png"
                        onReleased: {
                            root.changeSettingPage(7)
                        }
                    }

                    // 关于我们
                    SettingButton {
                        id: aboutusBtn
                        Layout.preferredWidth: 256
                        Layout.preferredHeight: 80
                        settingBtnText: "关于我们"
                        defBtnImgUrl: "qrc:/icons/setting_aboutus.png"
                        hoveredBtnImgUrl: "qrc:/icons/setting_aboutus_hovered.png"
                        onReleased: {
                            root.aboutUs()
                        }
                    }

                    // 帮助
                    SettingButton {
                        id: helpBtn
                        Layout.preferredWidth: 256
                        Layout.preferredHeight: 80
                        settingBtnText: "帮助"
                        defBtnImgUrl: "qrc:/icons/setting_help.png"
                        hoveredBtnImgUrl: "qrc:/icons/setting_help_hovered.png"
                        onReleased: {
                            root.help()
                        }
                    }
                }
            }
        }
    }
}
